package com.yu.controller;

import com.yu.entity.User;
import com.yu.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (User)表控制层
 *
 * @author makejava
 * @since 2021-07-01 14:33:19
 */
@Controller
@RequestMapping("user")
public class UserController {
    /**
     * 服务对象
     */
    @Resource
    private UserService userService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public User selectOne(Integer id) {
        return this.userService.queryById(id);
    }

    //登陆
    /**
     * 通过用户查询用户
     * @param user 参数
     * @return  用户
     */
    @RequestMapping("login")
    @ResponseBody
    public String queryByUser(User user){
        System.out.println(user);
        User user1 = this.userService.queryByUser(user);
        System.out.println(user1);

        if(user1 != null){
            return "success";
        }else{
            return "fail";
        }
    }


}
